package com.terren.excavator.config;

import java.io.FileInputStream;
import java.util.Properties;
import org.apache.log4j.PropertyConfigurator;

import com.terren.excavator.util.LoggerUtil;

/**
 * 通过配置文件，在启动时，初始化
 * @author Administrator
 *
 */
public class ConfigInfo {

	public final static String SESSION_USER = "sessionLoginUser";//存入session 的key
	public static String LUCENE_USER_NAME;
	public static String LUCENE_PASS_WORD;
	
	public final static String downloadHtmlPath = "downloadHtml";
	
	/**
	 * lucene index 文件夹 主路径
	 */
	public static String LUCENE_INDEX_PATH;
	
	/* ================================================== */
	/**
	 * 初始化 config
	 */
	public static void initConfig(String filePath) throws Exception{
		Properties property = new Properties();
		PropertyConfigurator.configure(filePath);
		property.load(new FileInputStream(filePath));
		
		/**
		 * 管理lucene账号相关，为了方便不做数据库账号处理
		 */
		LUCENE_USER_NAME = property.getProperty("luceneUserName").trim();
		LUCENE_PASS_WORD = property.getProperty("lucenePassWord").trim();
		
		LUCENE_INDEX_PATH = property.getProperty("luceneIndexPath").trim();
		
		LoggerUtil.logInfo("lucene index main path : " + LUCENE_INDEX_PATH);
	}
}
